﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data.SqlClient;
using System.Data;
namespace DAO
{
    public class BIENPHIEUMUONSACHDAO
    {
        public int laysothutuphieumuonhientai()
        {
            SqlConnection conn = DATAPROVIDER.ConnectSQL();
            string sql = "SELECT GiaTri FROM BIEN_PHIEU_MUON_SACH WHERE TenBien='PMS'";
            SqlCommand cmd = new SqlCommand(sql, conn);
            object temp = cmd.ExecuteScalar();
            int dem = Convert.ToInt32(temp.ToString());
            conn.Dispose();
            return dem;
        }

        public int capnhatsothutuphieumuon()
        {
            BIENPHIEUMUONSACHDAO dao = new BIENPHIEUMUONSACHDAO();
            int kq = dao.laysothutuphieumuonhientai();
            kq++;
            SqlConnection conn = DATAPROVIDER.ConnectSQL();
            string SQL = "UPDATE BIEN_PHIEU_MUON_SACH SET GiaTri = '" + kq.ToString() + "' WHERE TenBien= 'PMS'";
            SqlCommand CMD = new SqlCommand(SQL, conn);
            kq = CMD.ExecuteNonQuery();
            conn.Dispose();
            return kq;
        }


    }
}
